<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<div id="content" class="span10">
	<!-- content starts -->

	<div>
		<ul class="breadcrumb">
			<li><a href="#">Home</a> <span class="divider">/</span></li>
			<li><a href="#">Leads</a> <span class="divider">/</span></li>
			<li><a href="#">View Lead</a></li>
		</ul>
	</div>

	<div class="row-fluid sortable">
		<div class="box span12">
			<div class="box-header well" data-original-title>
				<h2>
					<fmt:message key="form.viewLead.title" />
				</h2>
				<div class="box-icon">
					<a href="#" class="btn btn-minimize btn-round"><i
						class="icon-chevron-up"></i></a>
				</div>
			</div>
			<div class="box-content">
				<div id="formsContent" class="form-horizontal">
					<div class="row-fluid">
						<div class="span12">
						<div id="btns" style="text-align: center ;">
						<shiro:hasRole name="callAdd">
							<a href="newCall?id=${leadDTO.id}" class="btn btn-success btn-large"><i class="icon-pencil icon-white"></i> New Call</a>
						</shiro:hasRole>
				        <shiro:hasRole name="appointmentAdd">
				           	 	<a href="newAppointment?id=${leadDTO.id}" class="btn btn-warning btn-large"><i class="icon-bookmark icon-white"></i> New Appointment</a>
				        </shiro:hasRole>
				        </div>
							<fieldset>
								<legend>
									<fmt:message key="form.lead.requiredinformation" />
								</legend>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group" id="fName">
											<label class="control-label"><fmt:message
													key="form.lead.fName" /></label>
											<div class="controls">
												<span>${leadDTO.fName}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group" id="companyName">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.company" /></label>
											<div class="controls">
												<span>${leadDTO.companyName}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.lName" /></label>
											<div class="controls">
												<span>${leadDTO.lName}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.leadStatus" /></label>
											<div class="controls">
												<span>${leadDTO.leadStatus}</span>
											</div>
										</div>
									</div>
								</div>
							</fieldset>

							<fieldset>
								<legend>
									<fmt:message key="form.lead.leadinformation" />
								</legend>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.title" /></label>
											<div class="controls">
												<span>${leadDTO.title}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.email" /></label>
											<div class="controls">
												<span>${leadDTO.email}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.phone" /> </label>
											<div class="controls">
												<span>${leadDTO.phone}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.rating" /></label>
											<div class="controls">
												<span>${leadDTO.rating}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.mobile" /></label>

											<div class="controls">
												<span>${leadDTO.mobile}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.sector" /></label>
											<div class="controls">
												<span>${leadDTO.industry}</span>
											</div>
										</div>
									</div>
								</div>
							</fieldset>
							<fieldset>
								<legend>
									<fmt:message key="form.lead.addressinformation" />
								</legend>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.street" /></label>
											<div class="controls">
												<span>${leadDTO.street}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.zipCode" /></label>
											<div class="controls">
												<span>${leadDTO.zipCode}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.city" /></label>
											<div class="controls">
												<span>${leadDTO.city.name}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.country" /></label>
											<div class="controls">
												<span>${leadDTO.country.countryName}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.area" /></label>
											<div class="controls">
												<span>${leadDTO.state}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.website" /></label>
											<div class="controls">
												<span>${leadDTO.webSite}</span>
											</div>
										</div>
									</div>
								</div>
							</fieldset>
							<fieldset>
								<legend>
									<fmt:message key="form.lead.additionalinformation" />
								</legend>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.inOutBound" /></label>
											<div class="controls">
												<span>${leadDTO.inOutBound}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.empNum" /></label>
											<div class="controls">
												<span>${leadDTO.numOfEmp}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.needAmount" /></label>
											<div class="controls">
												<span>${leadDTO.carsNum}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.annualRevenue" /></label>
											<div class="controls">
												<span>${leadDTO.annualRevenue}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.category" /></label>
											<div class="controls">
												<span>${leadDTO.category}</span>
											</div>
										</div>
									</div>
									<div class="span6 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.leadsource" /></label>
											<div class="controls">
												<span>${leadDTO.leadSource}</span>
											</div>
										</div>
									</div>
								</div>
								<div class="row-fluid">
									<div class="span12 bgcolor">
										<div class="control-group">
											<label class="control-label" for="input"><fmt:message
													key="form.lead.description" /></label>
											<div class="controls">
												<span>${leadDTO.description}</span>
											</div>
										</div>
									</div>
								</div>
							</fieldset>
							<fieldset>
								<legend>
									<fmt:message key="view.appointmentsTable.title" />
								</legend>
								<table
									class="table table-striped table-bordered table-condensed">
									<thead>
										<tr>
											<th>Actions</th>
											<th>Sales Man</th>
											<th>Contacted Person</th>
											<th>Date</th>
											<th>Meeting Done</th>
											<th>Deal Closing Done</th>
											<th>Next Follow Up</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${appointments}" var="appointment">
											<tr class="even">
												<td>
													<div class="btn-group">
														<button class="btn btn-success dropdown-toggle"
															data-toggle="dropdown" data-hover="dropdown">
															Actions<span class="caret"></span>
														</button>
														<ul class="dropdown-menu">
															<shiro:hasRole name="appointmentEdit">
																<li><a
																	href="editAppointment?id=${appointment.id }&parentId=${leadDTO.id}">Edit</a></li>
															</shiro:hasRole>
															<shiro:hasRole name="appointmentView">
																<li><a href="viewAppointment?id=${appointment.id }">View</a></li>
															</shiro:hasRole>
														</ul>
													</div>
												</td>
												<td>${appointment.salesMan.fName}</td>
												<td>${appointment.contactedPerson.fName}</td>
												<c:choose>
													<c:when test="${appointment.date==null}">
														<td></td>
													</c:when>
													<c:otherwise>
														<c:set var="date" value="${appointment.date}" />
														<c:set var="datesubstring"
															value="${fn:substring(date, 0, 10)}" />
														<c:set var="datesplit"
															value="${fn:split(datesubstring, '-')}" />
														<c:set var="day" value="${datesplit[2]}" />
														<c:set var="month" value="${datesplit[1]}" />
														<c:set var="year" value="${datesplit[0]}" />
														<td>${day}/${month}/${year}</td>
													</c:otherwise>
												</c:choose>
												<td><c:choose>
														<c:when test="${appointment.meetingDone == true}">Yes</c:when>
														<c:when test="${appointment.meetingDone == false}">No</c:when>
														<c:otherwise>
														</c:otherwise>
													</c:choose></td>
												<td><c:choose>
														<c:when test="${appointment.dealClosingDone == true}">Yes</c:when>
														<c:when test="${appointment.dealClosingDone == false}">No</c:when>
														<c:otherwise>
														</c:otherwise>
													</c:choose></td>
												<td><c:choose>
														<c:when test="${appointment.nextFollowUp == true}">Yes</c:when>
														<c:when test="${appointment.nextFollowUp == false}">No</c:when>
														<c:otherwise>
														</c:otherwise>
													</c:choose></td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
							</fieldset>

							<fieldset>
								<legend>
									<fmt:message key="view.callsTable.title" />
								</legend>
								<table
									class="table table-striped table-bordered table-condensed">
									<thead>
										<tr>
											<th>Action</th>
											<th>CRM Staff</th>
											<th>Contacted Person</th>
											<th>Date</th>
											<th>In/Out</th>
											<th>Next Follow Up</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${calls}" var="call">
											<tr class="even">
												<td>
													<div class="btn-group">
														<button class="btn btn-success dropdown-toggle"
															data-toggle="dropdown" data-hover="dropdown">
															Actions<span class="caret"></span>
														</button>
														<ul class="dropdown-menu">
															<shiro:hasRole name="callEdit">
																<li><a
																	href="editCall?id=${call.id }&parentId=${leadDTO.id}">Edit</a></li>
															</shiro:hasRole>
															<shiro:hasRole name="callView">
																<li><a href="viewCall?id=${call.id }">View</a></li>
															</shiro:hasRole>
														</ul>
													</div>
												</td>
												<td>${call.crmStaff.fName}</td>
												<td>${call.contactedPerson.fName}</td>
												<c:choose>
													<c:when test="${call.date==null}">
														<td></td>
													</c:when>
													<c:otherwise>
														<c:set var="date" value="${call.date}" />
														<c:set var="datesubstring"
															value="${fn:substring(date, 0, 10)}" />
														<c:set var="datesplit"
															value="${fn:split(datesubstring, '-')}" />
														<c:set var="day" value="${datesplit[2]}" />
														<c:set var="month" value="${datesplit[1]}" />
														<c:set var="year" value="${datesplit[0]}" />
														<td>${day}/${month}/${year}</td>
													</c:otherwise>
												</c:choose>
												<td><c:choose>
														<c:when test="${call.inOutCall == true}">In</c:when>
														<c:when test="${call.inOutCall == false}">Out</c:when>
														<c:otherwise>
														</c:otherwise>
													</c:choose></td>
												<td><c:choose>
														<c:when test="${call.nextFollowUp == true}">Yes</c:when>
														<c:when test="${call.nextFollowUp == false}">No</c:when>
														<c:otherwise>
														</c:otherwise>
													</c:choose></td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
							</fieldset>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--/span-->

	</div>
	<!--/row-->
	<!-- content ends -->
</div>
<!--/#content.span10-->
<hr />